<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>一个案例</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
    <script src="../js/vue.js"></script>
    <div id ="app">
        <ul>
            <li class="{active:currentIdenx === index}" v-for="{book,index} in books" @click="btnClick(index)">{{index}}-{{book}}</li>
        </ul>
    </div>
    <script>
        let app = new Vue({
            el:"#app",
            data:{ 
               books:['十宗罪','金瓶梅','诈骗','传销'
                ],
               currentIdenx:''
            },
            methods:{
                btnClick(i){
                    this.currentIdenx =i
                }
            }
    })
    </script>
</body>
</html>